﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using ThirdLife.UI.WinForms.Modules;

namespace ThirdLife.UI.WinForms.Controls
{
  public partial class TLAddressBar : UserControl, IDockableUserControlView
  {
    private AddressBarUIModule _module;

    public TLAddressBar(AddressBarUIModule module)
    {
      _module = module;
      InitializeComponent();
      toolStripButtonMetaverseDisconnect.Visible = false;
      toolStripButtonHome.Image = ThirdLifeResources.Instance.GetImage("HomeImage");
      toolStripButtonHome.ToolTipText = ThirdLifeResources.Instance.GetText(("ToolTipAddresBarHomeButton"));
      toolStripButtonGridList.Image = ThirdLifeResources.Instance.GetImage("GridListImage");
      toolStripButtonGridList.ToolTipText = ThirdLifeResources.Instance.GetText("ToolTipAddresBarGridListButton");
      toolStripButtonMetaverseDisconnect.Image = ThirdLifeResources.Instance.GetImage("DisconnectImage");
      toolStripButtonMetaverseDisconnect.ToolTipText = ThirdLifeResources.Instance.GetText("ToolTipDisconnectButton");
      
    }

    public void SetupView()
    {
    }

    public void DestroyView()
    {

    }

    public int ControlId
    {
      get { return 2  ; }
    }

    public object Control
    {
      get { return this; }
    }

    public void ShowMetaverseDisconnectButton()
    {
      toolStripButtonMetaverseDisconnect.Visible = true;
    }

    private void toolStripButtonMetaverseDisconnect_Click(object sender, EventArgs e)
    {
      _module.DisconnectFromMetaverse();
    }

    public void HideMetaverseDisconnectButton()
    {
      toolStripButtonMetaverseDisconnect.Visible = false;
    }

    private void TLAddressBar_KeyDown(object sender, KeyEventArgs e)
    {
      if( e.KeyCode == Keys.Enter)
      {
        _module.ConnectToGridUsingDefaultUserNamePass(toolStripTextBoxAddress.Text);
      }
    }

    private void toolStripButtonGridList_Click(object sender, EventArgs e)
    {
      _module.BringUpGridList();
    }

    private void toolStripButtonHome_Click(object sender, EventArgs e)
    {
      _module.ConnectToHomeGrid();
    }
  }
}
